<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Feuilleprojet extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idfeuilleprojet;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Idprojetsregional;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idfeuilles;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Titre;


    /**
     * Parent relation fk_feuilleprojet_listeprojetsregional1
     *
     * @var Application_Model_Listeprojetsregional
     */
    protected $_Listeprojetsregional;

    /**
     * Parent relation fk_feuilleprojet_feuilles1
     *
     * @var Application_Model_Feuilles
     */
    protected $_Feuilles;


    /**
     * Dependent relation fk_donneeregionals_feuilleprojet1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Donneeregionals
     */
    protected $_Donneeregionals;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idfeuilleprojet'=>'Idfeuilleprojet',
            'idprojetsregional'=>'Idprojetsregional',
            'idfeuilles'=>'Idfeuilles',
            'titre'=>'Titre',
        ));

        $this->setParentList(array(
            'FkFeuilleprojetListeprojetsregional1'=> array(
                    'property' => 'Listeprojetsregional',
                    'table_name' => 'Listeprojetsregional',
                ),
            'FkFeuilleprojetFeuilles1'=> array(
                    'property' => 'Feuilles',
                    'table_name' => 'Feuilles',
                ),
        ));

        $this->setDependentList(array(
            'FkDonneeregionalsFeuilleprojet1' => array(
                    'property' => 'Donneeregionals',
                    'table_name' => 'Donneeregionals',
                ),
        ));
    }

    /**
     * Sets column idfeuilleprojet
     *
     * @param int $data
     * @return Application_Model_Feuilleprojet
     */
    public function setIdfeuilleprojet($data)
    {
        $this->_Idfeuilleprojet = $data;
        return $this;
    }

    /**
     * Gets column idfeuilleprojet
     *
     * @return int
     */
    public function getIdfeuilleprojet()
    {
        return $this->_Idfeuilleprojet;
    }

    /**
     * Sets column idprojetsregional
     *
     * @param string $data
     * @return Application_Model_Feuilleprojet
     */
    public function setIdprojetsregional($data)
    {
        $this->_Idprojetsregional = $data;
        return $this;
    }

    /**
     * Gets column idprojetsregional
     *
     * @return string
     */
    public function getIdprojetsregional()
    {
        return $this->_Idprojetsregional;
    }

    /**
     * Sets column idfeuilles
     *
     * @param int $data
     * @return Application_Model_Feuilleprojet
     */
    public function setIdfeuilles($data)
    {
        $this->_Idfeuilles = $data;
        return $this;
    }

    /**
     * Gets column idfeuilles
     *
     * @return int
     */
    public function getIdfeuilles()
    {
        return $this->_Idfeuilles;
    }

    /**
     * Sets column titre
     *
     * @param text $data
     * @return Application_Model_Feuilleprojet
     */
    public function setTitre($data)
    {
        $this->_Titre = $data;
        return $this;
    }

    /**
     * Gets column titre
     *
     * @return text
     */
    public function getTitre()
    {
        return $this->_Titre;
    }

    /**
     * Sets parent relation Idprojetsregional
     *
     * @param Application_Model_Listeprojetsregional $data
     * @return Application_Model_Feuilleprojet
     */
    public function setListeprojetsregional(Application_Model_Listeprojetsregional $data)
    {
        $this->_Listeprojetsregional = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idprojetsregional'];
        }

        $this->setIdprojetsregional($primary_key);

        return $this;
    }

    /**
     * Gets parent Idprojetsregional
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Listeprojetsregional
     */
    public function getListeprojetsregional($load = true)
    {
        if ($this->_Listeprojetsregional === null && $load) {
            $this->getMapper()->loadRelated('FkFeuilleprojetListeprojetsregional1', $this);
        }

        return $this->_Listeprojetsregional;
    }

    /**
     * Sets parent relation Idfeuilles
     *
     * @param Application_Model_Feuilles $data
     * @return Application_Model_Feuilleprojet
     */
    public function setFeuilles(Application_Model_Feuilles $data)
    {
        $this->_Feuilles = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idfeuilles'];
        }

        $this->setIdfeuilles($primary_key);

        return $this;
    }

    /**
     * Gets parent Idfeuilles
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Feuilles
     */
    public function getFeuilles($load = true)
    {
        if ($this->_Feuilles === null && $load) {
            $this->getMapper()->loadRelated('FkFeuilleprojetFeuilles1', $this);
        }

        return $this->_Feuilles;
    }

    /**
     * Sets dependent relations fk_donneeregionals_feuilleprojet1
     *
     * @param array $data An array of Application_Model_Donneeregionals
     * @return Application_Model_Feuilleprojet
     */
    public function setDonneeregionals(array $data)
    {
        $this->_Donneeregionals = array();

        foreach ($data as $object) {
            $this->addDonneeregionals($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_donneeregionals_feuilleprojet1
     *
     * @param Application_Model_Donneeregionals $data
     * @return Application_Model_Feuilleprojet
     */
    public function addDonneeregionals(Application_Model_Donneeregionals $data)
    {
        $this->_Donneeregionals[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_donneeregionals_feuilleprojet1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Donneeregionals
     */
    public function getDonneeregionals($load = true)
    {
        if ($this->_Donneeregionals === null && $load) {
            $this->getMapper()->loadRelated('FkDonneeregionalsFeuilleprojet1', $this);
        }

        return $this->_Donneeregionals;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Feuilleprojet
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Feuilleprojet());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Feuilleprojet::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdfeuilleprojet() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idfeuilleprojet = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdfeuilleprojet()));
    }
}
